<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">模块：</label>
                        <div class="layui-input-block">
                            <select id="modtype" name="modtype" lay-filter="modtype">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="enginname" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">款项说明</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhai" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">收款方</label>
                        <div class="layui-input-block">
                            <input type="text" name="duier" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">请款日期</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="dt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">支付方式</label>
                        <div class="layui-input-block">
                            <input type="text" name="incdaotype" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">流程单号</label>
                        <div class="layui-input-block">
                            <input type="text" name="sericnum" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">付款单号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">款项类型</label>
                        <div class="layui-input-block">
                            <input type="text" name="feilei_name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">费用项</label>
                        <div class="layui-input-block">
                            <input type="text" name="feitype_name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <input type="hidden" id="payss" name="payss">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <?php include 'dao.php' ?>

            <div class="layui-col-md10" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    var param_enginid = getQueryVariable('enginid') || 0;
    var param_modtype = getQueryVariable('modtype') || 0;


    var currButAuth, currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('支付管理');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_kuan_zhi_list),where: {enginid:param_enginid,modtype:param_modtype}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);

                var leftarr = res.data.leftarr;
                $("#payss_all").html(leftarr.all);
                $("#payss_no").html(leftarr.no);
                $("#payss_bu").html(leftarr.bu);
                $("#payss_quan").html(leftarr.quan);
                $("#payss_wu").html(leftarr.wu);



                xiala_zhan_one_zuo('modtype',res.data.modtype, res.data.is_modtype)


                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field: 'paystate_name', title: '支付状态'}
                ,{field: 'modtype_name', title: '模块'}
                ,{field:'sericnum',title:'单据编号',templet: function(d){
                    return '<span class="colorlan" onclick="openPage(\'../'+d.modenum+'/show.php?id='+d.mid+'\');">'+d.number+'</span>';
                }}
                ,{field:'status',title:'审核状态',templet: function(d){
                    if(d.status == 1){
                        return '<div style="text-align: center"><span class="list_billid billstrlv" onclick="openPage(\'../'+d.modenum+'/show.php?id='+d.mid+'\');">审批通过</span></div>'
                    }else if(d.status == 5){
                        return '<div style="text-align: center"><span class="list_billid billstrshoudong" onclick="openPage(\'../'+d.modenum+'/show.php?id='+d.mid+'\');">作废</span></div>'
                    }else{
                        return '';
                    }
                }}
                ,{field: 'zhai', title: '款项摘要'}
                ,{field: 'feilei_name', title: '款项类型'}
                ,{field: 'feitype_name', title: '费用项'}
                ,{field:'money',title:'申请付款金额(元)',totalRow: true,templet: function(d){
                        return parseFormatNum(d.money);
                    }}
                ,{field: 'incdaotype', title: '支付方式'}
                ,{field: 'duier', title: '收款方'}
                ,{field: 'banknum', title: '账户账号'}
                ,{field: 'bankname', title: '开户行'}
                ,{field:'payfee',title:'已支付(元)',totalRow: true,templet: function(d){
                        return parseFormatNum(d.payfee);
                    }}
                ,{field: 'flowuser', title: '申请人'}
                ,{field: 'created_at', title: '申请日期'}
                ,{field: 'enginname', title: '项目名称'}
                ,{field: 'engin_chanid_name', title: '项目所属单位'}
                ,{fixed: 'right', title:'操作', toolbar: '#test-dropdown-toolbar-barDemo',align:'center',width:200}
            ]]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){
                            if(currButAuth[key].butname == 'pay'){
                                if(currTabData[index].modtype == 18){
                                    continue;
                                }
                            }

                            if(currButAuth[key].butname == 'pay'){
                                if(currTabData[index].status == 5){
                                    continue;
                                }
                            }

                            if(currButAuth[key].butname == 'delete'){
                                if( !(currTabData[index].status == 5 && currTabData[index].paystate == 0) ){
                                    continue;
                                }
                            }

                            chk.append(' <a ' +
                                'href="javascript:;" ' +
                                'class="bar_opt layui-hide" ' +
                                'lay-event="search" ' +
                                'data-butname="'+currButAuth[key].butname+'" ' +
                                'data-title="'+currButAuth[key].title+'" ' +
                                'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                '>'+currButAuth[key].title+'' +
                                '</a>');
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });


        listTableSearch(form, table);
    });


    function auth_but_func_show(buttitle, index){
        var trData = currTabData[index];
        openPage('../'+trData.modenum+'/show.php?id='+trData.mid);
    }


    function auth_but_func_detail(buttitle, index){
        var trData = currTabData[index];
        openPage('../account_list/detail.php?kuanid='+trData.id);
    }
    function auth_but_func_pay(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('../account_list/addpay.php?close=1&kuanid='+trData.id);
    }
    function auth_but_func_delete(buttitle, index){
        var trData = currTabData[index];
        data_delete(ask_kuan_del, {id:trData.id});
    }

</script>
</body>
</html>
